   package cn.edu.bzu.aaa.until;

   import com.mchange.v2.c3p0.ComboPooledDataSource;

   import javax.sql.DataSource;
   import java.sql.Connection;
   import java.sql.SQLException;

   public class C3P0Util {
       private static ComboPooledDataSource dataSource = new ComboPooledDataSource();

       static {
           try {
               dataSource.setDriverClass("com.mysql.cj.jdbc.Driver");
               dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/work");
               dataSource.setUser("root");
               dataSource.setPassword("123456");
               dataSource.setMinPoolSize(5);
               dataSource.setMaxPoolSize(20);
               dataSource.setAcquireIncrement(5);
               dataSource.setMaxIdleTime(1800);
           } catch (Exception e) {
               e.printStackTrace();
           }
       }

       public static DataSource getDataSource() {
           return dataSource;
       }

       public static Connection getConnection() throws SQLException {
           return dataSource.getConnection();
       }
   }
   